<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			window.onload = function(){
				var str = "JavaScript 是 Web 的编程语言。所有现代的 HTML 页面都使用 Javascript。JavaScript 非常容" + 
				"易学。本教程将教你学习从初级到高级 javaScript 知识。";
				// to upper
				console.log("* * * * * * * * * * * * * * * * *");
				console.log("Grace never gone to style.");
				console.log("");
				console.log("section 1 -- to upper");
				console.log("");
				
				console.log(str.toUpperCase());
				
				console.log("");
				console.log("* * * * * * * * * * * * * * * * *");
				console.log("");
				
				// to lower
				console.log("section 2 -- to lower");
				console.log("");
				
				console.log(str.toLowerCase());
				
				console.log("");
				console.log("* * * * * * * * * * * * * * * * *");
				console.log("");
				
				// split and foreach
				console.log("sectoin 3 -- split and foreach");
				console.log("");
				
				var arr = str.split(" ");
				for(var i = 0; i < arr.length; i++){
					console.log(arr[i]);
				}
				
				console.log("");
				console.log("* * * * * * * * * * * * * * * * *");
				console.log("");
				
				// find JavaScript exist times in str
				console.log("section 4 -- find JavaScript exist times in str");
				console.log("");
				
				var count = 0;
				var findWord = "JavaScript".toLowerCase();
				var newstr = str.toLowerCase();
				var arrFind = newstr.split(findWord);
				console.log("JavaScript 一共出现了: " +( arrFind.length - 1 )+ " 次");
				
				console.log("");
				console.log("* * * * * * * * * * * * * * * * *");
				console.log("");
				
				// find between WEB and HTML str, nothing with space.
				console.log("section 5 -- find between WEB and HTML str, nothing with space");
				console.log("");
				
				var betWordOne = "Web";
				var betWordTwo = "HTML";
				
				var betStr = str.substr(str.indexOf(betWordOne) + betWordOne.length, str.indexOf(betWordTwo) - str.indexOf(betWordOne));
				var trimArr = betStr.split(" ");
				var trimStr = "";
				
				for (var i = 0; i < trimArr.length; i++) {
					trimStr = trimStr + trimArr[i];
				}
				
				console.log(trimStr);
				
				console.log("");
				console.log("* * * * * * * * * * * * * * * * *");
				console.log("");
				
				// tofixed four digital for round
				console.log("section 6 -- tofixed four digital for round");
				console.log("");
				
				var PI = 3.1415926535897932384626;
				var precision = PI.toFixed(4);
				console.log(precision);
				
				console.log("");
				console.log("* * * * * * * * * * * * * * * * *");
				console.log("");
				
				// judge if current time after 8:00 am, console out "上课".
				console.log("section 7 -- judge if current time after 8:00 am, console out \"上课\".");
				console.log("");
				
				var currentTime = new Date();
				var currentHour = currentTime.getHours();
				
				if (currentHour > 8) {
					console.log("上课了, 现在 " + currentTime + " 了, 你莫要饮茶了.");
				}
				
				console.log("");
				console.log("* * * * * * * * * * * * * * * * *");
			}
		</script>
	</head>
	<body>
	</body>
</html>
